<template>
    <div class="news_b">
        <Header/>
        <div class="third_show bh_400">
            <img src="../assets/temp/bb2_a_web.jpg" class="imgshow">
            <div class="text pages_w1145" v-if="getnewsdatas">
                <div class="title"><p>{{getnewsdatas.newsdata.name}}</p></div>
                <div class="txt"><span class="time">{{getnewsdatas.newsdata.intime|gdate('yyyy/MM/dd')}}</span></div>
            </div>
        </div>
        <div class="second_box">
            <div class="pages_w1145 pa_70 fl-clr" data-details="rd"  v-if="getnewsdatas">
            <div class="bw_850 fl">
                <div class="scientific_details">

                    <div class="text" v-html="getnewsdatas.newsdata.content">
                    </div>
                    <div class="details_bottom fl-clr">
                        <a v-if="!getnewsdatas.pn.p" href="javascript:void(0);" class="a prev"></a>
                        <router-link class="a prev" v-if="getnewsdatas.pn.p" :to="{name: 'news_details', params :{cid:$route.params.cid,id:getnewsdatas.pn.p.id}}"></router-link>
                        <router-link class="a return" :to="{name: 'news', query :{id:getnewsdatas.newsdata.cid}}"></router-link>

                        <a v-if="!getnewsdatas.pn.n" href="javascript:void(0);" class="a next"></a>
                        <router-link class="a next" v-if="getnewsdatas.pn.n" :to="{name: 'news_details', params :{cid:$route.params.cid,id:getnewsdatas.pn.n.id}}"></router-link>
                    </div>
                </div>
            </div>
            <div class="bw_260 fr" data-details="rdbox">
                <div class="scientific_rd">
                    <div class="scientific_title" v-if="getnewsdatas.casedata.id==12">推荐新闻</div>
                    <div class="scientific_title" v-else>推荐资讯</div>

                    <ul class="ul scientific_list">
                        <li v-for="(item,index) in getnewsdatas.newslist" :key="index" v-show="index<3">
                            <div class="title"><router-link :to="{name: 'news_details', params :{cid:$route.params.cid,id:item.id}}">{{item.name}}</router-link><!-- <a :href="geturl(item.id)">{{item.name}}</a> --></div>
                            <div class="time">{{item.intime|gdate('yyyy/MM/dd')}}</div>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
        </div>
        <Footer/>

    </div>
</template>


<script>
import Header from '../components/Header.vue'
import Footer from '../components/Footer.vue'
export default {
    components: {
        Footer,Header
    },
    created() {
    this.$axios
            .get(this.$store.state.domain+'/Multi/index.json', {
                params: {
                    id: this.$route.params.id
                }
            })
            .then(response => {
                this.$store.commit('menunewsapi',response.data);
            })
            .catch(error => {
                console.log(error);

            });
    },
    computed: {
        getnewsdatas(){
            return this.$store.getters.getnewsdata
        }
    },
    methods:{
        geturl(id) {
            return '/news_details?id='+id;
        }
    },
    mounted () {
        $(window).scroll(function(){
            if($('[data-details="rd"]').length>0){
                if ($(window).scrollTop()>$('[data-details="rd"]').offset().top) {
                    $('[data-details="rdbox"]').addClass('details-fixed-r');
                } else {
                    $('[data-details="rdbox"]').removeClass('details-fixed-r');
                }
            }
        })
    }
}

</script>
